<%--
  Created by IntelliJ IDEA.
  User: 22531
  Date: 2021/6/8
  Time: 20:57
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <link rel="stylesheet" type="text/css" href="/easyui/themes/default/easyui.css">
    <link rel="stylesheet" type="text/css" href="/easyui/themes/icon.css">
    <script type="text/javascript" src="/easyui/jquery.min.js"></script>
    <script type="text/javascript" src="/easyui/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="/js/jquery.edatagrid.js"></script>
    <script src="/easyui/locale/easyui-lang-zh_CN.js"></script>
</head>
<body>

<div class="easyui-panel" data-options="fit:true,border:false">
    <table id="UpTea"></table>
</div>
<script type="text/javascript">
    $(function () {
        $('#UpTea').edatagrid({
            url: '/admin/getAllTeaWithPage',
            saveUrl: '/admin/adAddTea',
            updateUrl: '/admin/adUpTea',
            destroyUrl: '/admin/adDelTea',
            columns:[[
                {field:"id",align:"center",title:'老师ID'},
                {field:"name",align:"center",title:'老师名称',editor:{type:'textbox',options:{required:true}}},
                {field:"password",align:"center" ,title:'密码',editor:{type:'textbox',options:{required:true}}},
                {field: "onJob",align: 'center',title: '在职状态',editor:{type:'combobox',
                            options:{
                                    valueField: 'label',
                                    textField: 'value',
                                    data: [{
                                        label: '在职',
                                        value: '在职'
                                    },{
                                    label: '离职',
                                    value: '离职'
                                    }],
                                    required:true,
                                    editable:false,
                            }
                    }
                }
            ]],
            iconCls: 'icon-edit',
            title:'增删改老师信息',
            singleSelect: true,
            method: 'get',
            rownumbers:true,
            pagination: true,
            pageSize:10,
            pageList:[10,20,30,40,50],
            idField:'id',
            toolbar: [{
                iconCls: 'icon-reload',
                text:'刷新',
                handler: function(){
                    $('#UpTea').edatagrid('reload');
                }
            },'-',{
                iconCls: 'icon-add',
                text: '新增老师',
                handler: function () {
                    $('#UpTea').edatagrid('addRow');
                },
            },/*'-',{
                iconCls: 'icon-remove',
                text: '删除老师',
                handler: function (){
                    $('#UpTea').edatagrid('destroyRow');
                },
            },*/'-',{
                iconCls: 'icon-save',
                text: '保存修改或新增操作',
                handler: function () {
                    $('#UpTea').edatagrid('saveRow');
                },
            },'-',{
                iconCls: 'icon-undo',
                text: '取消',
                handler: function () {
                    $('#UpTea').edatagrid('cancelRow');
                },
            }],
            onSuccess:function (index,row){
                if(row.msg){
                    $.messager.alert('操作结果','操作成功!','info');
                    $('#UpTea').edatagrid('reload');
                }
                else {
                    $.messager.alert('操作结果','操作失败!'+row.error,'warning');
                    $('#UpTea').edatagrid('reload');
                }
            },
            onError:function (index,row){
                $.messager.alert('error','服务器错误!','warning');
                $('#UpTea').edatagrid('reload');
            }
        });
    });
</script>
</body>
</html>


